/*
 * Created on 15.10.2006 by leck
 *
 */
package de.devisnik.eidle.flashlight;

import java.util.Random;


public class ShapeFactory implements IShapeFactory {
    
    private Random itsRandom;

    public ShapeFactory() {
        itsRandom = new Random(System.currentTimeMillis());
    }
    
    public IShape createCircle(int radius) {
        return new Circle(radius);
    }

    public IShape createPolygon(int radius, int corners) {
        return new Polygon(corners, radius);
    }

    public IShape createShape(int radius) {
        int number = itsRandom.nextInt(4);
        switch (number) {
            case 0:
                return createCircle(radius);
            case 1:
                return createPolygon(radius, 3+ itsRandom.nextInt(12));
            case 2:
                return createStar(radius, 5+ 2*itsRandom.nextInt(4));
            case 3:
                return createSquare(radius);

            default:
                break;
        }
        return null;
    }

    public IShape createSquare(int radius) {
        return new Square(radius);
    }

    public IShape createStar(int radius, int corners) {
        return new Star(corners, radius);
    }

}
